import  sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import time
class ThDemo(QWidget):
    def __init__(self,parent=None):
        super(ThDemo,self).__init__(parent)
        self.setWindowTitle("th案例")
        self.listFile=QListWidget()
        self.btnStart=QPushButton('开始')
        layout=QGridLayout(self)
        layout.addWidget(self.listFile,0,0,1,2)
        layout.addWidget(self.btnStart,1,1)
        self.btnStart.clicked.connect(self.slotAdd)
        self.setLayout(layout)
    def slotAdd(self,info):

        for n in range(20):
            str_n="File index{0}".format(n)
            self.listFile.addItem(str_n)
            QApplication.processEvents()
            time.sleep(1)


if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=ThDemo()

    demo.show()
    sys.exit(app.exec_())
